"""
@Time ： 2021/11/11 10:45
@Auth ： ChenZhangKun
"""
from selenium import webdriver
from selenium.webdriver.common.by import By

webDriver = webdriver.Chrome(r'D:\sofwares\chrom\chromedriver.exe')

webDriver.get('http://cdn1.python3.vip/files/selenium/sample1b.html')

# 选择span为第二个子节点的元素
elements = webDriver.find_elements(By.CSS_SELECTOR, "span:nth-child(2)")

for e in elements:
    print(e.get_attribute("outerHTML"))

# 倒数第二个p节点
elementss = webDriver.find_elements(By.CSS_SELECTOR, "p:nth-last-child(2)")
for e in elementss:
    print(e.get_attribute("outerHTML"))
# element = webDriver.find_element(By.CSS_SELECTOR, '[href="http://www.miitbeian.gov.cn"]')
# 点击
# if element is not None:
#     element.click()
